import React, { Component } from 'react'
// 类组件,用于对比
export default class Stateclass extends Component {
    state = {
        age:10,
        name:'张三'
    }
    add = () => {
        let { age } = this.state
        age +=1;
        this.setState({age})
    }    
    render() {
        return (
            <div>
                <h2> {this.state.age} </h2>
                <button onClick={this.add}> 点击我增加年龄</button>
            </div>
        )
    }
}
